package com.jianqiao.delivery.config;

import net.sourceforge.tess4j.Tesseract;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: 图片文字识别配置类
 * @author: lsx
 * @create: 2024-11-25 14:34
 **/
@Configuration
public class TesseractOcrConfig {

    @Value("${tess4j.datapath}")
    private String dataPath;

    @Bean
    public Tesseract tesseract() {

        Tesseract tesseract = new Tesseract();
        // 设置训练数据文件夹路径
        tesseract.setDatapath(dataPath);
        // 设置要识别的语言为简体中文、日语和印尼语和英文
        tesseract.setLanguage("chi_sim+jpn+ind+eng");
        return tesseract;
    }

}

